/**
 * Author: Seppe Staes 
 * Project: Credoc - eDossier 
 * Date: 04/2013
 * 
 * Description: Some dummy data from local json file and load into LocalStorage
 * 				'./json/edossiers.json'
 * 
 * Conceptual Model v0.1:
 * 
 * 		Edossier
 * 			Deeds
 * 			Parties
 * 			Goods
 * 			Documents
 * 
 */

window.store = {
	populate : function() {
		
		// create a dummy edossier collection
		edossiers = new EdossierCollection();
		edossiers.fetch({
			url:'json/edossiers.json',
			success: function(model, response) {
				// now create the localStorage
				edossiers.localStorage = new Backbone.LocalStorage('edossiers');
				// loop through the edossiers collection and create entries in localStorage
				edossiers.each(function(edossier){ 
					edossiers.create( edossier );
				  });
			}
		});		
		edossiers.bind('reset', function() { 
		      console.log('collection has been loaded (reset event)');  
		}); 
		
		// add dashboard to breadcrumb items, so it can be rendered
		// TODO: Get translations!
		window.breadcrumb = new BreadcrumbItemCollection();
		var inital = new BreadcrumbItem();
		inital.set({ id: "1", item: "Dashboard", url: ""}); // relative path to dashboard, see router in main.js
		breadcrumb.add(this.initial);
		
	},
};
